import java.awt.*;
import java.util.Iterator;
import java.util.Random;

/**
 * Created by hasee on 2017/8/23.
 */
public class Food {
    Node food;
    static int cro;
    static int ver;
    static int foodsize;//食物大小
    static boolean live=false;//表示是否存在食物
    static int foodScore=25;//食物所值分数

    public void makeFood() {
        if (live==true){return;}
        cro = new Random().nextInt(25)+3;
        ver = new Random().nextInt(25)+1;
        this.food = new Node(cro, ver);
        foodsize=food.blocksize;
        foodScore=25;
        live=true;
        return;
    }

    public void refreshFood(Iterator i){
        Node node;
        while (i.hasNext()){
            node= (Node) i.next();
            if(node.cro==food.cro&&node.ver==food.ver){
                live=false;
                System.out.println("重新生成啦");
                makeFood();
                return;
            }
        }
    }

    public void draw(Graphics g){
        food.drawFood(g,foodsize);
    }
}
